﻿using AutoDeployForSims.Entity;
using AutoDeployForSims.Service;
using AutoDeployForSims.Utility;
using MyUtility.Utility;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AutoDeployForSims.ViewModel
{
    public class FrankCFGInfoControlViewModel:ViewModelBase
    {
        private GetConfigService getConfigService = SingletonProvider<GetConfigService>.Instance;
        List<FrankCFGInfoEntity> frankCFGInfos = new List<FrankCFGInfoEntity>();

        #region ViewModel

        private ObservableCollection<CommInfoControlViewMode> tabs = new ObservableCollection<CommInfoControlViewMode>();

        public ObservableCollection<CommInfoControlViewMode> Tabs
        {
            get { return tabs; }
            set
            {
                tabs = value;
                RaisePropertyChanged("Tabs");
            }
        }        

        #endregion

        public FrankCFGInfoControlViewModel()
        {
            Initial();
        }

        private void Initial()
        {
            if (getConfigService.ReadFrankConfig(ref frankCFGInfos))
            {
                int num = frankCFGInfos.Count;
                Tabs.Clear();
                for (int i = 0; i < num; i++)
                {
                    CommInfoControlViewMode CommInfoControlVM = new CommInfoControlViewMode(frankCFGInfos[i]);
                    CommInfoControlVM.FrankCFGInfoEnt.Title = frankCFGInfos[i].Title;                    
                    CommInfoControlVM.FrankCFGInfoEnt.CommIP = frankCFGInfos[i].CommIP;
                    CommInfoControlVM.FrankCFGInfoEnt.CommInfoEntities = frankCFGInfos[i].CommInfoEntities;

                    Tabs.Add(CommInfoControlVM);
                }

            }
        }

        public void GetFrankCFGInfo()
        {
            
        }
    }

}
